home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 March
/
EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso
/
earcd
/
util1
/
pubfictn.lha
/
pubfiction.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-10
|
6KB
|
180 lines
/* Name: pubfiction.c
Descr: Open/close a public screen with selectable resolution, clone pens from workbench.
Date: 10-Nov-1995
Author: Henrik Wetterström a.k.a. Procyon
Email: hwefri92@tufvan.hv.se
Smail: Who cares?
Other: Works fine on my 68EC030 and MicroVitec multiscan monitor (in lots of resolutions)
but since I have little experience in C programming on the Amiga (I usually code
C in Unix or assembler on the Amiga) could I have missed some detail. Feel free
to finger point them to me if you find them...
The background to this little utility is that one guy (forgot the name) asked
about such utility on IRC #amiga and I pointed to a PAL/NTSC only version
called PSX. Later I figured out that it should be easy to make one, and it
actually was easy... :)
Copyright:
If you are able to earn some money from this material then go ahead and do so, BUT
you must tell me HOW you did it. However, I would find it extremely cool to find a
greeting to me in a product that gained from this material, so please greet me if
you use it.
Disclaimer:
I can not assure one thing about this product, it could trash your computer,
infect you with syphilis, make you sister pregnant, help you to win the lottery,
explode your monitor. No matter what it does to you, it is all your fault and
responsibility. If you are the sensitive or lawyer kind of person do I suggest
that you make you own program instead of using this.
Greetings:
My old fellas in Digital Technology, my drinking brothers in Brothers in Beer,
the dudes on #amiga, all babes worldwide, all breweries worldwide, all the
folks here at Växjö University, Honko del Oro.
Whishes:
Peace and freedom for everyone, SparcCenter 2000e, SGI Onyx, BeBox,
free sex & beer, etc...
Comment:
The name (PubFiction) is a smartass name from the great movie "Pulp fiction"
which I still have not seen, but it looks like I am the only person on this
planet who have not seen it so I guess I will see it alone...
If this program had a scroller would this text been there... :)
*/
#define INTUI_V36_NAMES_ONLY
#include <string.h>
#include <ctype.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <dos/rdargs.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/intuition_protos.h>
struct Library *IntuitionBase;
ULONG mode=0L;
struct Screen *getpubscreen( ULONG modeid, long depth, char *name, int shanghai, int popup ) {
struct Screen *wbscreen,*myscreen=NULL;
struct TagItem screentags[5];
struct DrawInfo *screen_drawinfo;
static UBYTE *wbname = "Workbench";
UWORD pm=0;
if( wbscreen=LockPubScreen(wbname) ) {
if ( screen_drawinfo=GetScreenDrawInfo(wbscreen) )
{
screentags[0].ti_Tag = SA_Pens;
screentags[0].ti_Data = (ULONG)(screen_drawinfo->dri_Pens);
screentags[1].ti_Tag = SA_DisplayID;
screentags[1].ti_Data = modeid;
screentags[2].ti_Tag = SA_Depth;
screentags[2].ti_Data = (ULONG)depth;
screentags[3].ti_Tag = SA_PubName;
screentags[3].ti_Data = (ULONG)name;
screentags[4].ti_Tag = TAG_END;
screentags[4].ti_Data = NULL;
FreeScreenDrawInfo(wbscreen,screen_drawinfo);
}
else {
screentags[0].ti_Tag = SA_DisplayID;
screentags[0].ti_Data = modeid;
screentags[1].ti_Tag = SA_PubName;
screentags[1].ti_Data = (ULONG)name;
screentags[2].ti_Tag = SA_Depth;
screentags[2].ti_Data = depth;
screentags[3].ti_Tag = TAG_END;
screentags[3].ti_Data = NULL;
}
if( myscreen=OpenScreenTagList(NULL, screentags) ) {
PubScreenStatus(myscreen,0);
if(shanghai) pm=SHANGHAI;
if(popup) pm=pm|POPPUBSCREEN;
SetDefaultPubScreen(name);
SetPubScreenModes(pm);
}
UnlockPubScreen(wbname,wbscreen);
}
return myscreen;
}
int modelong( char *s ) {
int i,b,l=strlen(s);
if( (l>2) && (l<10) && (s[0]=='0') && (s[1]=='x' ) ) {
for(i=2;i<l;i++) {
mode=mode<<4;
b=0xff & toupper(s[i]);
switch(b) {
case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':
b=0xf & (b-'0');
mode=mode|b;
break;
case 'A':case 'B':case 'C':
case 'D':case 'E':case 'F':
b=0xf & (b-'A'+10);
mode=mode|b;
break;
default:
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
int closepubscreen(char *name) {
struct Screen *scr;
int r=FALSE;
if(scr=LockPubScreen(name)) {
UnlockPubScreen(name,scr);
r=CloseScreen(scr);
}
return r;
}
int main(int argc, char **argv) {
char template[]="OPEN/S,CLOSE/S,PUBNAME/K,MODEID/K,DEPTH/N,SHANGHAI/S,POPUP/S";
LONG args[]={0,0,0,0,0,0,0};
struct RDArgs *argp;
static char defname[]="Procyon";
char *pnam=defname;
long dep=3;
if( argp=ReadArgs(template,args,NULL) ) {
if( args[0]==FALSE && args[1]==FALSE ) {
VPrintf("Open or close operation not specified.\n",NULL);
FreeArgs(argp);
return 10;
}
if(args[2]) pnam=(char *)args[2];
if(args[3]) {
if( (modelong((char *)args[3]))==FALSE ) {
VPrintf("Invalid modeid.\n",NULL);
FreeArgs(argp);
return 10;
}
}
else mode=0x99004;
if(args[4]) dep=*(long *)args[4];
if ( IntuitionBase= OpenLibrary("intuition.library",37L) ) {
if( args[0] ) {
if( getpubscreen(mode,dep,pnam,(int)args[5] ,(int)args[6] )==NULL )
VPrintf("Failed to open screen.\n",NULL);
}
if( args[1] ) {
if( args[2]==NULL ) VPrintf("No screen name was passed.\n",NULL);
else if( closepubscreen((char *)args[2])==FALSE)
VPrintf("Failed to close screen '%s'.\n",&args[2]);
}
CloseLibrary(IntuitionBase);
}
FreeArgs(argp);
}
}